/**
* 版权声明：厦门睿商网络科技有限公司 版权所有 违者必究
* 日    期：2020-04-27
*/
package com.rzico.basics.service;

import com.alibaba.fastjson.JSON;
import com.rzico.basics.entity.CardTag;
import com.rzico.basics.mapper.CardMapper;
import com.rzico.base.BaseMapper;
import com.rzico.base.impl.BaseServiceImpl;
import com.rzico.basics.entity.Card;
import com.rzico.basics.entity.Company;
import com.rzico.basics.entity.Enterprise;
import com.rzico.basics.entity.Member;
import com.rzico.basics.model.CardView;
import com.rzico.util.DateUtils;
import com.rzico.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.util.*;

/**
 * <pre>
 * 会员卡业务类
 * </pre>
 *
 * @author Rzico Boot
 * @version 1.0
 */
@Service
public class CardService extends BaseServiceImpl<Card, String> {

    @Autowired
    private CardMapper cardMapper;

    @Override
    public BaseMapper<Card, String> getMapper() {
        return cardMapper;
    }

    /**
     * 统计卡余额及福利金
     */
    public CardView summary(Long memberId) {
        return cardMapper.summary(memberId);
    }
    /**
     * 获取有效会员卡及专属卡
     */
    public List<Card> getEffectiveCard(Long memberId) {
        return cardMapper.getEffectiveCard(memberId);
    }

    /**
     * 获取企业所有批次卡
     * @param params
     * @return
     */
    public List<Card> getComapnyCard(Map<String, Object> params){
        return cardMapper.getComapnyCard(params);
    }

    @Override
    public int updateByPrimaryKeySelective(Card card) {
        card.setBalance(null);
        return cardMapper.updateByPrimaryKeySelective(card);
    }
}
